package com.ku.log.facade;

import com.ku.log.entity.SysLog;
import com.ku.log.service.LogService;
import com.ku.log.vo.LogQueryVo;
import com.ku.log.vo.PagingLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author: GZQ
 * @create: 2020/08/09
 * @description: 操作日志门面，暴露给外部手动调用的接口
 **/
@Component
public class LogManager {

    private static LogService logService;

    /**
     * 静态变量通过setter注入
     * @param logService logService
     */
    @Autowired
    public void setService(LogService logService) {
        LogManager.logService = logService;
    }

    /**
     * 暴露接口，添加操作日志
     */
    public static void addLog(SysLog sysLog) {
        logService.addLog(sysLog);
    }

    /**
     * 暴露接口，查询操作日志
     */
    public static List<LogQueryVo> queryLog(LogQueryVo logQueryVo) {
        return logService.queryLog(logQueryVo);
    }

    /**
     * 暴露接口，分页查询操作日志
     */
    public static PagingLog queryPagingLog(LogQueryVo logQueryVo) {
        PagingLog pagingLog = new PagingLog();
        pagingLog.setCount(logService.countQueryLog(logQueryVo));
        pagingLog.setList(logService.queryLog(logQueryVo));
        return pagingLog;
    }

    /**
     * 暴露接口，更新操作目标
     */
    public static void setLogDesc(String desc) {
        logService.setLogDesc(desc);
    }

    public static void descApend(String desc) {
        logService.descAppend(desc);
    }

    public static void failed() {
        logService.failed();
    }

    public static void updateType(String type) {
        logService.updateType(type);
    }

    public static void updateItem(String item) {
        logService.updateItem(item);
    }

    public static void updateModule(String module) {
        logService.updateModule(module);
    }

}
